<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ attribute name="totalCount" type="java.lang.String" required="true" description="总页数"%>
<link rel="stylesheet" href="/static/layui/css/layui.css"  media="all">
<div id="pager"></div>
<script src="/static/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript">
    /*替换url参数
    * @param url url
    * @param arg 参数
    * @param 替换值
    * */
    function changeURLArg(url,arg,arg_val){
        var pattern=arg+'=([^&]*)';
        var replaceText=arg+'='+arg_val;
        if(url.match(pattern)){
            var tmp='/('+ arg+'=)([^&]*)/gi';
            tmp=url.replace(eval(tmp),replaceText);
            return tmp;
        }else{
            if(url.match('[\?]')){
                return url+'&'+replaceText;
            }else{
                return url+'?'+replaceText;
            }
        }
        return url+'\n'+arg+'\n'+arg_val;
    }

    //完整功能
    layui.use(['laypage', 'layer'], function() {
        var laypage = layui.laypage
            , layer = layui.layer;
        laypage.render({
            elem: 'pager'
            ,count: ${totalCount}
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
            ,jump: function(obj,first){
                if (!first)
                {
                    //layer.msg('第 '+ obj.curr +' 页' +' mei ye shu liang'+obj.limit);
                    var url = window.location.href ;
                     window.location.href = changeURLArg(url,"pageIndex", obj.curr);
                }
            }
        });
    });
</script>
